/*
 * LED.h
 *
 *  Created on: May 22, 2022
 *      Author: LDSCITECHE
 */

#ifndef MYBSP_TM1640_H_
#define MYBSP_TM1640_H_

#include "sn_config.h"


//定义TM1640的16个GRID（16个不同的显存空间，或者说16个数码管的公共端）
#define TM1640_GRID1  ((uint8_t)0)
#define TM1640_GRID2  ((uint8_t)1)
#define TM1640_GRID3  ((uint8_t)2)
#define TM1640_GRID4  ((uint8_t)3)
#define TM1640_GRID5  ((uint8_t)4)
#define TM1640_GRID6  ((uint8_t)5)
#define TM1640_GRID7  ((uint8_t)6)
#define TM1640_GRID8  ((uint8_t)7)
#define TM1640_GRID9  ((uint8_t)8)
#define TM1640_GRID10  ((uint8_t)9)
#define TM1640_GRID11  ((uint8_t)10)
#define TM1640_GRID12  ((uint8_t)11)
#define TM1640_GRID13  ((uint8_t)12)
#define TM1640_GRID14  ((uint8_t)13)
#define TM1640_GRID15  ((uint8_t)14)
#define TM1640_GRID16  ((uint8_t)15)

//定义TM1640的亮度级别
#define TM1640_BRIGHT1  ((uint8_t)0)
#define TM1640_BRIGHT2  ((uint8_t)1)
#define TM1640_BRIGHT3  ((uint8_t)2)
#define TM1640_BRIGHT4  ((uint8_t)3)
#define TM1640_BRIGHT5  ((uint8_t)4)
#define TM1640_BRIGHT6  ((uint8_t)5)
#define TM1640_BRIGHT7  ((uint8_t)6)
#define TM1640_BRIGHT8  ((uint8_t)7)


#define  TM_SCL_GPIO  		 	GPIO1
#define  TM_SCL_GPIO_Pin  	GPIO_Pin_8


#define  TM_SDA_GPIO  		 	GPIO1
#define  TM_SDA_GPIO_Pin  	GPIO_Pin_9


#define TM_SCL_H()  GPIO_SetBits(TM_SCL_GPIO,TM_SCL_GPIO_Pin)
#define TM_SCL_L()  GPIO_ResetBits(TM_SCL_GPIO,TM_SCL_GPIO_Pin)

#define TM_SDA_H()  GPIO_SetBits(TM_SDA_GPIO,TM_SDA_GPIO_Pin)
#define TM_SDA_L()  GPIO_ResetBits(TM_SDA_GPIO,TM_SDA_GPIO_Pin)

#define  read_DIN   GPIO_ReadOutputDataBit(TM_SDA_GPIO,TM_SDA_GPIO_Pin)

#define  DELAY_TIME     1






void tm1640_gpio_init(void);
void tm1640_init(void);
void tm1640_handle(void);

#endif /* MYBSP_LED_H_ */
